<template>
  <!--基本信息  -->
  <div>
    <FormPanel
      ref="infoActivityDialog"
      :list="initForm"
      :cols="2"
      :formType="value.type"
      :labelWidth="110"
      :isSubmitBtn="false"
      @formChange="formChangeHandle"
    />
    <!-- 选择车型 -->
    <BaseDialog
      title="选择车型"
      :visible.sync="visibleDialog"
      width="700px"
      destroyOnClose
      :containerStyle="{height: 'calc(100% - 60px)', overflow: 'auto', paddingBottom: '60px'}"
    >
      <typeCar   @close="closeTypeCarDialog" />
    </BaseDialog>
    <div class="dialogBottmView">
      <el-button @click="closeDialog">取 消</el-button>
      <el-button @click="saveDialog" type="primary">保 存</el-button>
    </div>
  </div>
</template>

<script>
import typeCar from './infoActivityTypeCar'
import { dictionary } from '@/utils/dictMixin';
export default {
  mixins: [dictionary],
   components: {
    typeCar
  },
  props: {
    value: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      visibleDialog:false,
      initForm: this.initFormFun(),
      formValue: {}
    };
  },
  mounted() {
    console.log(this.value); //获取到行id 、类型（新增、详情）
    //请求接口进行赋值，自己写吧
  },
  methods: {
    //搜索数据
    initFormFun() {
      return [
        {
          type: 'INPUT',
          label: '活动车型',
          fieldName: 'field1',
          initialValue: '',
          unitRender: () => {
            return <el-button slot="append" icon="el-icon-search" onClick={() => this.openDialog()}></el-button>;
          },
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {
          type: 'SELECT',
          label: '是否必做',
          fieldName: 'field2',
          placeholder: '请选择',
          initialValue: '',
          itemList: this.createDictList('1008'),
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        { type: 'INPUT', label: '活动地点', fieldName: 'field3', placeholder: '请输入', initialValue: '' },
        {
          type: 'RANGE_DATE',
          label: '活动周期',
          fieldName: 'field21',
          valueFormat: 'yyyy-MM-dd', //返回数据格式
          initialValue: ['2019-08-12', '2019-09-18'],
          placeholder: '请选择',
          style: { width: '100%' },
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {
          type: 'DATE',
          label: '活动时间',
          fieldName: 'DATE',
          valueFormat: 'yyyy-MM-dd', //返回数据格式
          initialValue: '2019-08-19',
          placeholder: '请选择',
          style: { width: '100%' },
          rules: [
            {
              required: true,
              message: '必填',
              trigger: 'change'
            }
          ]
        },
        {
          type: 'TEXT_AREA',
          label: '活动名称',
          fieldName: 'field11',
          rows: 2,
          initialValue: '',
          placeholder: '请输入',
          rules: [{ required: true, message: '错误提示信息', trigger: 'blur' }]
        },
        {
          type: 'TEXT_AREA',
          label: '活动主题',
          fieldName: 'field11',
          rows: 3,
          initialValue: '',
          placeholder: '请输入',
          rules: [{ required: true, message: '错误提示信息', trigger: 'blur' }] //验证
        },
        {
          type: 'TEXT_AREA',
          label: '活动目的',
          fieldName: 'field12',
          rows: 2,
          initialValue: '',
          placeholder: '请输入',
          rules: [{ required: true, message: '错误提示信息', trigger: 'blur' }] //验证
        },
        {
          type: 'TEXT_AREA',
          label: '活动形式',
          fieldName: 'field13',
          rows: 2,
          initialValue: '',
          placeholder: '请输入',
          rules: [{ required: true, message: '错误提示信息', trigger: 'blur' }] //验证
        }
      ];
    },
    openDialog() {
      this.visibleDialog = true;
    },
    closeTypeCarDialog(data) {
      this.visibleDialog =false; //关闭弹窗
       //返回数据逻辑自己写
    },
    formChangeHandle(val) {
      this.formValue = val;
      this.$emit('close', { visible: false });
    },
    //保存
    saveDialog() {
      this.$refs.infoActivityDialog.SUBMIT_FORM();
    },
    //取消操作
    closeDialog() {
      this.$emit('close', { visible: false });
    }
  }
};
</script>